#!/bin/bash

function dump() {
	OUTDIR=/vagrant/output/export
	OUTFILE=$OUTDIR/$SITENAME.tar
	if [ ! -d $OUTDIR ]
	then
		mkdir -p $OUTDIR
	fi
	
	SITEDIR=/var/www/$PLATFORM/sites/$SITENAME
	
	echo "Exporting DB $SITEDIR to $OUTFILE"
	
	cd $SITEDIR
	drush -q -y archive-dump $SITENAME --no-core --destination=$OUTFILE
}


if [ $# -eq 2 ]
then
	PLATFORM=$1
	SITENAME=$2
	
	dump
else
	echo "Usage: site_export.sh <platform_name> <fqdn_site>"
	exit -1
fi
